/obj/structure/stool/bed/roller_cmo
	name = "CMO roller bed"
	icon = 'CMO.dmi'
	icon_state = "down"
	anchored = 0

/obj/item/roller_cmo
	name = "CMO roller bed"
	desc = "A collapsed roller bed that can be carried around."
	icon = 'CMO.dmi'
	icon_state = "folded"
	w_class = 3.0

	attack_self(mob/user)
		var/obj/structure/stool/bed/roller_cmo/R = new /obj/structure/stool/bed/roller_cmo(user.loc)
		R.add_fingerprint(user)
		del(src)

/obj/structure/stool/bed/roller_cmo/buckle_mob(mob/M as mob, mob/user as mob)
	if ((!( istype(M, /mob) ) || get_dist(src, user) > 1 || M.loc != src.loc || user.restrained() || usr.stat || M.buckled || istype(usr, /mob/living/silicon/pai)))
		return
	M.pixel_y = 6
	M.update_clothing()
	density = 1
	icon_state = "up"
	..()
	return

/obj/structure/stool/bed/roller_cmo/manual_unbuckle(mob/user as mob)
	if(buckled_mob)
		buckled_mob.pixel_y = 0
		buckled_mob.anchored = 0
		buckled_mob.buckled = null
		buckled_mob = null
	density = 0
	icon_state = "down"
	..()
	return

/obj/structure/stool/bed/roller_cmo/MouseDrop(over_object, src_location, over_location)
	..()
	if((over_object == usr && (in_range(src, usr) || usr.contents.Find(src))))
		if(!ishuman(usr))	return
		if(buckled_mob)	return 0
		visible_message("[usr] collapses \the [src.name]")
		new/obj/item/roller_cmo(get_turf(src))
		spawn(0)
			del(src)
		return